import { createBrowserRouter } from 'react-router-dom'
import { Navigate } from 'react-router-dom'



import App from '../App'
import WaterManagement from '../pages/zzy/WaterManagement'
import GuangaiDongtai from '../pages/zzy/WaterMetering/GuangaiDongtai'
import Guangai from '../pages/zzy/WaterMetering/Guangai'
import HistoryData from '../pages/zzy/WaterMetering/HistoryData'
import HistoryTable from '../pages/zzy/WaterMetering/HistoryTable'
import Yujing from '../pages/zzy/Property/Yujing'
import Layout from '../pages/zzy/Property/Layout'
import Gongdan from '../pages/zzy/Property/Gongdan'
import Chuli from '../pages/zzy/Property/Chuli'
import Shenhe from '../pages/zzy/Property/Shenhe'
import Tongji from '../pages/zzy/Property/Tongji'
import Shenchu from '../pages/zzy/Property/Shenchu'

import { lazy, Suspense } from 'react'
import { Skeleton } from 'antd'
const Home = lazy(() => import('../pages/Home'))
const Login = lazy(() => import('../pages/Login'))
const EngineeringSecurity = lazy(() => import('../pages/jwh/Engineering-security'))
const ErrorCaptured = lazy(() => import('../pages/yzf/errorCaptured'))
const Service = lazy(() => import('../pages/Service'))

//路由鉴权
import PrivateRoute from '../api/csy/PrivateRoute'

//运行管理页面
const Yun = lazy(() => import('../pages/csy/Operations/index'))
//巡查巡检页面
const RunManagement = lazy(() => import('../pages/csy/Operations/Inspection/index'))
//巡查页面--轨迹
const Gui = lazy(() => import('../pages/csy/Operations/Inspection/Rixun/index'))


//日常巡检页面
const DailyInspection = lazy(() => import('../pages/csy/Operations/Inspection/Riinspection'))
//定期检查页面
const RegularInspection = lazy(() => import('../pages/csy/Operations/Inspection/DingSpection'))
//特别检查页面
const SpecialInspection = lazy(() => import('../pages/csy/Operations/Inspection/SpecialInspection/special'))
const indexSpecial = lazy(() => import('../pages/csy/Operations/Inspection/SpecialInspection/index'))
//子特别检查页面
const addSpecialInspection = lazy(() => import('../pages/csy/Operations/Inspection/SpecialInspection/addSpecial'))
//安全检查页面
const SafetyInspection = lazy(() => import('../pages/csy/Operations/Inspection/SafetyInspection/safety'))



//日常维修
const indexDaily = lazy(() => import('../pages/csy/Operations/Maintenance/DeviceList/index'))

const DailyMaintenance = lazy(() => import('../pages/csy/Operations/Maintenance/DeviceList/deviceList'))
//发起维修
const MaintenanceSend = lazy(() => import('../pages/csy/Operations/Maintenance/DeviceList/addDevicel'))
//待审核页面
const MaintenanceAudit = lazy(() => import('../pages/csy/Operations/Maintenance/DeviceList/addcomponent/Shen'))

//日常养护
const DailyMaintenance1 = lazy(() => import('../pages/csy/Operations/Maintenance/DeviceHuo/Devceho'))

// 数据中心
const DataCenter = lazy(() => import('../pages/jwh/Datecenter'))
// 灌区概况
const Overview = lazy(() => import('../pages/jwh/Overview'))
// 人员岗位
const Post = lazy(() => import('../pages/jwh/Post'))
// 智控中心
const Alerts = lazy(() => import('../pages/jwh/Alerts'))

const Table = lazy(() => import('../pages/csy/Operations/Inspection/Dingcha/index'))
//定期检查页面发送
const SendTable = lazy(() => (import('../pages/csy/Operations/Inspection/Dingcha/sendtable')))


//维修养护页面
const MaintenanceManagement = lazy(() => import('../pages/csy/Operations/Maintenance/index'))

// const Operational = lazy(() => import('../pages/csy/Operations/index'))

//杨章富页面路由
//应急管理页面
const EmergencyManagement = lazy(() => import('../pages/yzf/Emergency'))
const EmergencyPlan = lazy(() => import('../pages/yzf/Emergency/EmergencyPlan'))
const EmergencyResponse = lazy(() => import('../pages/yzf/Emergency/emergencyResponse'))
const EmergencyExercise = lazy(() => import('../pages/yzf/Emergency/emergencyExercise'))
const EmergencyStock = lazy(() => import('../pages/yzf/Emergency/emergencyStock'))
const WareHouse = lazy(() => import('../pages/yzf/Emergency/wareHouse'))

// 隐患中心页面
const HiddenDanger = lazy(() => import('../pages/yzf/hiddenDanger'))
const HiddenDangerAssignPerson = lazy(() => import('../pages/yzf/hiddenDanger/assignPerson'))
const HiddenDangerRepair = lazy(() => import('../pages/yzf/hiddenDanger/hiddenDangerRepair'))
const HiddenDangerRepairResult = lazy(() => import('../pages/yzf/hiddenDanger/hiddenDangerRepairResult'))
const HiddenDangerAudit = lazy(() => import('../pages/yzf/hiddenDanger/hiddenDangerAudit'))



const router = createBrowserRouter([
    {
        path: '/',
        element:
            <App />
        ,
        children: [
            {
                path: '/home',
                element:
                    <PrivateRoute Childer={Home}></PrivateRoute>
                ,
                children: [
                    {
                        path: 'Engineering-security',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <PrivateRoute Childer={EngineeringSecurity}></PrivateRoute>
                            </Suspense>,
                    },
                    {
                        path: 'ErrorCaptured',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <PrivateRoute Childer={ErrorCaptured}></PrivateRoute>

                            </Suspense>,
                    },
                    {
                        path: 'water',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <PrivateRoute Childer={WaterManagement}></PrivateRoute>
                            </Suspense>,
                    },

                ]
            },
            {
                path: '/service',
                element:
                    <Suspense fallback={<Skeleton active />}>
                        <Service />
                    </Suspense>,
                children: [
                    {
                        path: 'DataCenter',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <DataCenter/>
                            </Suspense>,
                        children: [
                            {
                                path: 'sub-1',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Overview />
                                    </Suspense>,
                            },
                            {
                                path: 'sub-2',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Post />
                                    </Suspense>,
                            },
                            {
                                path: 'sub-3',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Post />
                                    </Suspense>,
                            },

                        ]
                    },
                    {
                        path: 'guangai',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <PrivateRoute Childer={Guangai}></PrivateRoute>
                            </Suspense>,
                    },
                    {
                        path: 'alerts',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <Alerts />
                            </Suspense>,

                    },
                    {
                        path: 'history',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <HistoryData />
                            </Suspense>,
                    },
                    {
                        path: 'histable',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <HistoryTable />
                            </Suspense>,
                    },
                    {
                        path: 'dongtai',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <GuangaiDongtai />
                            </Suspense>,
                    },
                   {
                    path: 'layout',
                    element:
                        <Suspense fallback={<Skeleton active />}>
                            <Layout />
                        </Suspense>,
                        children: [
                            {
                                path: 'yujing',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Yujing />
                                    </Suspense>,
                            },
                            {
                                path: 'gongdan',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Gongdan />
                                    </Suspense>,
                            },
                            {
                                path: '/service/layout/gongdan/chuli',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Chuli />
                                    </Suspense>,
                            },
                            {
                                path:'/service/layout/gongdan/shenhe',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Shenhe />
                                    </Suspense>,
                            },
                            {
                                path: 'tongji',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Tongji />  
                                    </Suspense>,
                            },
                            {
                                path: 'shenchu',
                                element:
                                    <Suspense fallback={<Skeleton active />}>
                                        <Shenchu />
                                    </Suspense>,
                            },
                        ]
                    },
                    {
                        path: 'Operational',
                        element:
                            <Suspense fallback={<Skeleton active />}>
                                <Yun />
                            </Suspense>,
                        children: [
                            //巡检页面
                            {
                                path: 'security',
                                element: <Suspense fallback={<Skeleton active />}>
                                    <PrivateRoute Childer={RunManagement}></PrivateRoute>
                                </Suspense>,
                                children: [
                                    //日常巡查页面
                                    {
                                        path: 'dailyInspection',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={DailyInspection}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    //定期检查页面
                                    {
                                        path: 'regularInspection',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={RegularInspection}></PrivateRoute>

                                        </Suspense>,
                                        children: [
                                            {
                                                path: 'table',
                                                element:
                                                    <Suspense fallback={<Skeleton active />}>
                                                        <PrivateRoute Childer={Table}></PrivateRoute>

                                                    </Suspense>,
                                            },
                                            {
                                                path: 'sendtable',
                                                element:
                                                    <Suspense fallback={<Skeleton active />}>
                                                        <PrivateRoute Childer={SendTable}></PrivateRoute>
                                                    </Suspense>,
                                            }
                                        ]
                                    },
                                    //日常巡查页面后的轨迹
                                    {
                                        path: 'gui',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={Gui}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    //特别检查
                                    {
                                        path: 'indexSpecial',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={indexSpecial}></PrivateRoute>
                                        </Suspense>,
                                        children: [
                                            {
                                                path: 'specialInspection',
                                                element:
                                                    <Suspense fallback={<Skeleton active />}>
                                                        <PrivateRoute Childer={SpecialInspection}></PrivateRoute>
                                                    </Suspense>,
                                            },
                                            {
                                                path: 'addSpecialInspection',
                                                element:
                                                    <Suspense fallback={<Skeleton active />}>
                                                        <PrivateRoute Childer={addSpecialInspection}></PrivateRoute>
                                                    </Suspense>,
                                            }
                                        ]
                                    },
                                    //安全检查
                                    {
                                        path: 'safetyInspection',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={SafetyInspection}></PrivateRoute>
                                        </Suspense>,
                                    }
                                ]
                            },
                            //维修养护
                            {
                                path: 'maintenance',
                                element: <Suspense fallback={<Skeleton active />}>
                                    <PrivateRoute Childer={MaintenanceManagement}></PrivateRoute>
                                </Suspense>,
                                children: [

                                    //维修页面
                                    {
                                        path: 'DailyMaintenance',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={indexDaily}></PrivateRoute>
                                        </Suspense>,
                                        children: [
                                            {
                                                path: 'indexDaily',
                                                element:
                                                    <Suspense fallback={<Skeleton active />}>
                                                        <PrivateRoute Childer={DailyMaintenance}></PrivateRoute>
                                                    </Suspense>,
                                            },
                                            {
                                                path: 'addDailyMaintenance',
                                                element:
                                                    <Suspense fallback={<Skeleton active />}>
                                                        <PrivateRoute Childer={MaintenanceSend}></PrivateRoute>
                                                    </Suspense>,
                                            },
                                            //待审核页面
                                            {
                                                path: 'Audit',
                                                element:
                                                    <Suspense fallback={<Skeleton active />}>
                                                        <PrivateRoute Childer={MaintenanceAudit}></PrivateRoute>
                                                    </Suspense>,
                                            },
                                            //审核通过页面
                                        
                                        ]
                                    },

                                    //养护页面
                                    {
                                        path: 'DailyMaintenance1',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={DailyMaintenance1}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    {
                                    }
                                ]
                            },
                            //应急管理
                            {
                                path: 'emergency',
                                element: <Suspense fallback={<Skeleton active />}>
                                    <PrivateRoute Childer={EmergencyManagement}></PrivateRoute>
                                </Suspense>,
                                children: [
                                    {
                                        path: 'emergencyPlan',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={EmergencyPlan}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    {
                                        path: 'emergencyResponse',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={EmergencyResponse}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    {
                                        path: 'emergencyExercise',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={EmergencyExercise}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    {
                                        path: 'emergencyStock',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={EmergencyStock}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    {
                                        path: 'wareHouse',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={WareHouse}></PrivateRoute>
                                        </Suspense>,
                                    }
                                ]
                            },
                            //隐患中心
                            {
                                path: 'hiddenDanger',
                                element: <Suspense fallback={<Skeleton active />}>
                                    <PrivateRoute Childer={HiddenDanger}></PrivateRoute>
                                </Suspense>,
                                children: [
                                    {
                                        path: 'hiddenDangerAssignPerson',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={HiddenDangerAssignPerson}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    {
                                        path: 'hiddenDangerRepair',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={HiddenDangerRepair}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    {
                                        path: 'hiddenDangerRepairResult',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={HiddenDangerRepairResult}></PrivateRoute>
                                        </Suspense>,
                                    },
                                    {
                                        path: 'hiddenDangerAudit',
                                        element: <Suspense fallback={<Skeleton active />}>
                                            <PrivateRoute Childer={HiddenDangerAudit}></PrivateRoute>
                                        </Suspense>,
                                    },
                                ]
                            },
                        ]
                    }
                ]
            },
            {
                path: '/login',
                element: <Login />
            },
            {
                path: '/',
                element: <Navigate to='/login' />
            }
        ]
    },

])



export default router